package com.itheima.config;

import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.FilterType;
import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @program: spring_base
 * @description:
 * @author: zhanghz001
 * @create: 2020-12-02 13:39
 **/
@ComponentScan(value = "com.itheima",
        includeFilters = {@ComponentScan.Filter(type = FilterType.ANNOTATION, classes =
                {org.springframework.stereotype.Controller.class})}
)
@Configuration
// @EnableWebMvc
public class SpringMVCConfig implements WebMvcConfigurer {
    //注解配置通用放行的资源格式
    //配置指定放行的资源文件
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/img/**").addResourceLocations("/img/");
        registry.addResourceHandler("/js/**").addResourceLocations("/js/");
        registry.addResourceHandler("/css/**").addResourceLocations("/css/");
    }

    @Override
    public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
        configurer.enable();
    }
}
